﻿<%@ Page Title="New Delivery" Language="C#" MasterPageFile="~/Pages/user/userMaster.Master" AutoEventWireup="true" CodeBehind="NewDelivery.aspx.cs" Inherits="WarehouseWebAPP.Pages.user.New_Entities.NewDelivery" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="style1">
        <tr>
            <td>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:DetailsView ID="DeliveredDetailsView" runat="server" AllowPaging="True" 
                    AutoGenerateRows="False" CellPadding="4" DataKeyNames="delivered_num" 
                    DataSourceID="NewDeliveryObjectDataSource" DefaultMode="Insert" 
                    ForeColor="#333333" GridLines="None" Height="50px" 
    Width="555px">
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <Fields>
                                <asp:BoundField DataField="delivered_num" HeaderText="delivered_num" 
                            ReadOnly="True" SortExpression="delivered_num" Visible="False" />
                                <asp:TemplateField HeaderText="Component Serial No." 
                            SortExpression="delivered_component">
                                    <EditItemTemplate>
                                        <asp:DropDownList ID="DropDownList1" runat="server" 
                                    DataSourceID="ComponentObjectDataSource" DataTextField="component_serial_num" 
                                    DataValueField="component_num" 
                                    SelectedValue='<%# Bind("delivered_component") %>'>
                                        </asp:DropDownList>
                                        <asp:ObjectDataSource ID="ComponentObjectDataSource" runat="server" 
                                    SelectMethod="ComponentGetData" 
                                    TypeName="WarehouseWebAPP.code.BLL.ComponentBLL"></asp:ObjectDataSource>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <cc1:ComboBox ID="ComboBox1" runat="server" AppendDataBoundItems="True" 
                                            AutoCompleteMode="Append" DataSourceID="ComponentObjectDataSource" 
                                            DataTextField="component_serial_num" DataValueField="component_num" 
                                            DropDownStyle="DropDownList" MaxLength="0" 
                                            SelectedValue='<%# Bind("delivered_component") %>' style="display: inline;">
                                        </cc1:ComboBox>
                                        <asp:ObjectDataSource ID="ComponentObjectDataSource" runat="server" 
                                    SelectMethod="ComponentGetData" 
                                    TypeName="WarehouseWebAPP.code.BLL.ComponentBLL"></asp:ObjectDataSource>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="ComponentLabel" runat="server" 
                                    Text='<%# Bind("delivered_component") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="User" SortExpression="delivered_user">
                                    <EditItemTemplate>
                                        <asp:DropDownList ID="DropDownList2" runat="server" 
                                    DataSourceID="UserObjectDataSource" DataTextField="user_name" 
                                    DataValueField="user_num" SelectedValue='<%# Bind("delivered_user") %>'>
                                        </asp:DropDownList>
                                        <asp:ObjectDataSource ID="UserObjectDataSource" runat="server" 
                                    SelectMethod="userGet" TypeName="WarehouseWebAPP.code.BLL.UserBLL">
                                        </asp:ObjectDataSource>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <cc1:ComboBox ID="ComboBox2" runat="server" AppendDataBoundItems="True" 
                                            AutoCompleteMode="Append" DataSourceID="UserObjectDataSource" 
                                            DataTextField="user_name" DataValueField="user_num" 
                                            DropDownStyle="DropDownList" MaxLength="0" 
                                            SelectedValue='<%# Bind("delivered_user") %>' style="display: inline;">
                                        </cc1:ComboBox>
                                        <asp:ObjectDataSource ID="UserObjectDataSource" runat="server" 
                                    SelectMethod="userGet" TypeName="WarehouseWebAPP.code.BLL.UserBLL">
                                        </asp:ObjectDataSource>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="UserLabel" runat="server" Text='<%# Bind("delivered_user") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Customer" 
                            SortExpression="delivered_customer">
                                    <EditItemTemplate>
                                        <asp:DropDownList ID="DropDownList4" runat="server" 
                                    DataSourceID="CustomerObjectDataSource" DataTextField="customer_name" 
                                    DataValueField="customer_num" 
                                    SelectedValue='<%# Bind("delivered_customer") %>'>
                                        </asp:DropDownList>
                                        <asp:ObjectDataSource ID="CustomerObjectDataSource" runat="server" 
                                    SelectMethod="CustomerGet" TypeName="WarehouseWebAPP.code.BLL.CustomerBLL">
                                        </asp:ObjectDataSource>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <cc1:ComboBox ID="ComboBox3" runat="server" AppendDataBoundItems="True" 
                                            AutoCompleteMode="Append" DataSourceID="CustomerObjectDataSource" 
                                            DataTextField="customer_name" DataValueField="customer_num" 
                                            DropDownStyle="DropDownList" MaxLength="0" 
                                            SelectedValue='<%# Bind("delivered_customer") %>' style="display: inline;">
                                        </cc1:ComboBox>
                                        <asp:ObjectDataSource ID="CustomerObjectDataSource" runat="server" 
                                    SelectMethod="CustomerGet" TypeName="WarehouseWebAPP.code.BLL.CustomerBLL">
                                        </asp:ObjectDataSource>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="CustomerLabel" runat="server" 
                                    Text='<%# Bind("delivered_customer") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Delivered Quantity" 
                            SortExpression="delivered_quantity">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox1" runat="server" 
                                    Text='<%# Bind("delivered_quantity") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <asp:TextBox ID="QuantityTextBox" runat="server" 
                                    Text='<%# Bind("delivered_quantity") %>'></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                            ControlToValidate="QuantityTextBox" ErrorMessage="*"></asp:RequiredFieldValidator>
                                        <asp:CustomValidator ID="CustomValidator1" runat="server" 
                                    ControlToValidate="QuantityTextBox" ErrorMessage="Overlarge Delivery" 
                                    onservervalidate="CustomValidator1_ServerValidate" 
                                    
                                    
                                            ToolTip="Delivery Quantity must be equal or less than the Component Quantity In the Warehouse. "></asp:CustomValidator>
                                        &nbsp;<asp:RangeValidator ID="RangeValidator1" runat="server" 
                                            ControlToValidate="QuantityTextBox" ErrorMessage="Value Range [1,1M]" 
                                            MaximumValue="1000000" MinimumValue="1" Type="Integer"></asp:RangeValidator>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("delivered_quantity") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Delivery Date" SortExpression="delivered_date">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("delivered_date") %>'></asp:TextBox>
                                        <cc1:CalendarExtender ID="TextBox2_CalendarExtender" runat="server" 
                                    Format="dd/MM/yyyy" TargetControlID="TextBox2">
                                        </cc1:CalendarExtender>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("delivered_date") %>'></asp:TextBox>
                                        <cc1:MaskedEditExtender ID="TextBox2_MaskedEditExtender" runat="server" 
                                            TargetControlID="TextBox2" Mask="99/99/9999" MaskType="Date" 
                    UserDateFormat="DayMonthYear">
                                        </cc1:MaskedEditExtender>
                                        <cc1:CalendarExtender ID="TextBox2_CalendarExtender" runat="server" 
                                    Format="dd/MM/yyyy" TargetControlID="TextBox2">
                                        </cc1:CalendarExtender>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                            ControlToValidate="TextBox2" ErrorMessage="*"></asp:RequiredFieldValidator>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="DateLabel" runat="server" Text='<%# Bind("delivered_date") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:CommandField ShowInsertButton="True" />
                            </Fields>
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <EditRowStyle BackColor="#999999" />
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        </asp:DetailsView>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <asp:ObjectDataSource ID="NewDeliveryObjectDataSource" runat="server" 
                    InsertMethod="DeliveredInsert" SelectMethod="DeliveredGet" 
                    TypeName="WarehouseWebAPP.code.BLL.DeliveredBLL">
                    <InsertParameters>
                        <asp:Parameter Name="delivered_component" Type="String" />
                        <asp:Parameter Name="delivered_user" Type="String" />
                        <asp:Parameter Name="delivered_customer" Type="String" />
                        <asp:Parameter Name="delivered_date" Type="DateTime" />
                        <asp:Parameter Name="delivered_quantity" Type="Int32" />
                    </InsertParameters>
                </asp:ObjectDataSource>
            </td>
        </tr>
    </table>
</asp:Content>
